<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <script src="./vue.js"></script>
</head>
<body>
<div id="app">
    <div>
        <input type="text" v-model="input_val"  @keyup.enter="addli">
    </div>
    <div>
        <ul v-for="(item,index) in list_data"  :key="index">
            <li>{{item.content}}
                <button @click="removeli(index)">删除</button>
            </li>
        </ul>
    </div>
</div>

<script>
    var vm = new Vue({
        el: '#app',
        data: {
            input_val:'',
            list_data: [
                {
                    content: '吃饭'
                },
                {
                    content: '睡觉'
                },
                {
                    content: '运动'
                }
            ]
        },
        methods: {
            addli() {
                this.list_data.unshift( {content: this.input_val})
            },
            removeli(index) {
                this.list_data.splice(index, 1)
            }
        }
    })
</script>

</body>
</html>
